import os

import yaml

from manager.config.Base_File_Config import BASE_DATA_PATH


def read_yaml(file_path):
    """
    读取指定路径的yaml文件
    :param file_path:  绝对路径
    :return:  yaml文件结果集
    """
    # 定义空列表 组装测试数据
    arr = []
    # 获取文件流
    with open(file_path, "r", encoding="utf-8") as f:
        # 遍历 调用yaml.safe_load(f).values()方法
        for datas in yaml.safe_load(f).values():
            arr.append(tuple(datas.values()))
        # 返回 结果
        return arr


def read_module_yaml(module, filename):
    """
    读取指定模块的yaml文件
    :param module: 模块名
    :param filename:  文件名
    :return:  yaml文件结果集
    """
    file_path = BASE_DATA_PATH + os.sep + module + os.sep + filename + '.yaml'
    # 定义空列表 组装测试数据
    arr = []
    # 获取文件流
    with open(file_path, "r", encoding="utf-8") as f:
        # 遍历 调用yaml.safe_load(f).values()方法
        for datas in yaml.safe_load(f).values():
            arr.append(tuple(datas.values()))
        # 返回 结果
        return arr
